package com.controller;

import com.mapper.DabianMapper;
import com.pojo.Dabian;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

@RestController
@RequestMapping("/dabian")
public class DabianController {

    @Autowired
    private DabianMapper dabianMapper;

    @PostMapping("/release")
    public void releaseDabian(@RequestBody Dabian teaminf){
//        if (teaminf.getState() == null) teaminf.setState(0);

        String courseName = teaminf.getCourseName();
//        Integer headTeacherId = teaminf.getHeadTeacherId();
        String headTeacherName = teaminf.getHeadTeacherName();
//        String secondTeacherName = teaminf.getSecondTeacherName();
//        String threadTeacherName = teaminf.getThreadTeacherName();
//        Integer studentId = teaminf.getStudentId();
//        String studentName = teaminf.getStudentName();

        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

         dabianMapper.insertDabianTeam2(courseName,headTeacherName);
//        dabianMapper.insertDabianTeam(courseName,headTeacherId,headTeacherName,secondTeacherName,threadTeacherName,studentId,studentName,timestamp,teaminf.getState());
//        dabianMapper.insertDabianTeam(teaminf);
    }

    @GetMapping("/getInf")
    public List<Dabian> getDabianInf(){


        List<Dabian> list = dabianMapper.selectList(null);

        return list;
    }

//    @PostMapping("/panduan")
//    public Map<String,Object> panduan(Integer state){
//        Map<String,Object> map = new HashMap<>();
//
//        Dabian dabian = new Dabian();
//
//        int code = 200;
//        String msg = "成功";
//
//        if (state == 1){
//            dabian.setState(state);
//            dabianMapper.updateById(dabian);
//            map.put("code",code);
//            map.put("msg",msg);
//        }else {
//            code = 500;
//            msg = "失败";
//            map.put("code",code);
//            map.put("msg",msg);
//        }
//
//        return map;
//    }
}
